public class MySingleList {
    public boolean contain(int key) {
        ListNode cur = head;
        while(cur != null) {
            if(key == cur.val) {
                return true;
            }
            cur = cur.next;
        }
        return false;
    }

    public int size() {
        ListNode cur = head;
        int i = 0;
        while(cur != null) {
            i++;
            cur = cur.next;
        }
        return i;
    }
}
